<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>选择配送企业</title>
<%@ include file="/WEB-INF/component/commonCSS.jsp"%>

<!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue sidebar-mini fixed skin-blue-light-frame">

	<section class="content">
		<div class=" box box-success">
			<div class="box-body">
				<div class="form-inline">
					<div class="form-group form-group-xs">
                                                                企业名称： <input class="form-control" type="text" id="sDelCompName" placeholder="企业名称" />
                    </div>
					<button  id="selectSeesDel" type="button" onclick="gridSerch();" class="btn btn-success btn-sm">查 询</button>
				</div> 
			</div>
		</div>


		<table class="jqgrid" id="gridlist"></table>
		<div id="gridpage"></div>
		<div class=" box box-warning bottongroup">
			<button type="button" onclick="compSelect();" class="btn btn-primary btn-sm">选 择</button>
		</div>
	</section>
	<%@ include file="/WEB-INF/component/commonJS.jsp"%>
	<script type="text/javascript">
	
	//绑定回车   id="selectSeesDel"
	$('#sDelCompName,#sDelCompCode').bind('keydown', function(event) {
	    if (event.keyCode == "13") {
	        $('#selectSeesDel').click();
	    }
	}); 
	$("#sDelCompName").focus();//加载页面光标在第一个查询框内
	
	//绑定回车   id="selectSee"
    $('#compName').bind('keydown', function(event) {
        if (event.keyCode == "13") {
            $('#selectSee').click();
        }
    }); 
    $("#compName").focus();//加载页面光标在第一个查询框内
	
        $(function () {
             $("#gridlist").jqGrid({
                url: "${ctx}/baseDelAreaRel/getCompList.html",
                mtype: "POST",
                datatype: "json",
                autowidth: true,
                height: 185,
				//shrinkToFit: false,
                colNames: ['企业编码','企业名称', '企业简称'],
                colModel: [
         			{ name: 'comp_code', hidden:true,width: 150, align: "center", sortable:false },
                    { name: 'comp_name', width: 400, align: "center", sortable:false },
                    { name: 'comp_short_name', width:155, align: "center", sortable:false }
                ],
                rowNum: 10,
                rowList: [10, 20, 50, 100],
                rownumbers: true,
                pager: "#gridpage",
               // multiselect: true, 
                viewrecords: true,
                caption: "配送企业选择", 	
                jsonReader: {
                    repeatitems: false,
                    id: "ids"
                },
                gridComplete:function(){
					//序号列宽度自适应（参数为jqgridID）
					autoRNWidth("gridlist");
					//数据只有一条时默认选中（参数为jqgridID）
					selectByOneData("gridlist");
	                }
            }); 
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $(window).trigger("resize");
        });
        
        function gridSerch() {
        	var compName = $.trim($("#sDelCompName").val());
    		$("#gridlist").jqGrid('setGridParam',{  
    	        datatype:'json',
    	        postData:{
    	        		"compName":compName
						},
    	        		page:1
    	    }).trigger("reloadGrid"); //重新载入  
    	}
        
        function compSelect(){
        	var rowIds = $("#gridlist").jqGrid("getGridParam", "selrow");
        	if (rowIds == null || rowIds == ""){
        		$.HN.message.alert('请选择配送企业！', '提示信息', 'warn');
        		return ;
        	}
        	 var rowdata = $("#gridlist").jqGrid('getRowData', rowIds[0]);
        	 var dialog = top.dialog.get(window);
        	 dialog.close("${param.delId}|$${param.delTxt}|$"+rowdata.comp_code+'|$'+rowdata.comp_name); // 关闭（隐藏）对话框
        	 dialog.remove();				 // 主动销毁对话框
 			return false;
        }
       
    </script>
</body>
</html>